const _config = {
  home_name: "规则更新",
  remote_update: 'https://gitee.com/shentong_012/HikerRules/raw/master/update.json',
  work_path: 'hiker://files/rules/',
}
if (!getVar('bfq')) { putVar('bfq', '1'); }
// common methods
function queryUpdate() {
  if (MY_URL.search("update_rule") > -1) {
    return true;
  }
  else {
    return false;
  }
};
function queryUpdateTimeOut() {
  let config = this.getLocalConfig();
  let now = new Date().getTime();
  if ((now - config.last_check_update_time) > 259200000) {
    return true;
  }
  return false;
};
function querySetting() {
  if (MY_URL.search("update_rule") > -1) {
    return true;
  }
  else {
    return false;
  }
};

function getRemoteCommandRoute(remote_command) {
  return fetch(remote_command, {});
};
function getLocalConfig() {
  let localConfig = fetch(_config.work_path + 'config.json', {});
  let localConfigObj = {};
  try {
    if (localConfig == '') {
      throw 'none';
    }
    else {
      localConfigObj = JSON.parse(localConfig);
      if (localConfigObj.item_list == undefined || localConfigObj.note == undefined || localConfigObj.setting == undefined) {
        throw 'undefined';
      }
    }
  } catch (e) {
    localConfigObj = {};
    localConfigObj.item_list = [];
    localConfigObj.note = [];
    localConfigObj.setting = [];
    writeFile(_config.work_path + 'config.json', JSON.stringify(localConfigObj));
  }
  return localConfigObj;
};
function getLocalItemVersionById(id, name) {
  let localConfigObj = getLocalConfig();
  let itemList = localConfigObj.item_list;
  for (let item of itemList) {
    if (item.id == id) {
      return item.version;
    }
  }
  itemList.push({
    name: name,
    id: id,
    version: "0"
  })
  writeFile(_config.work_path + 'config.json', JSON.stringify(localConfigObj));
  return "0";
};
function setLocalItemVersionById(id, version) {
  let localConfigObj = getLocalConfig();
  let itemList = localConfigObj.item_list;
  for (let i = 0; i < itemList.length; i++) {
    if (itemList[i].id == id) {
      itemList[i].version = version;
      writeFile(_config.work_path + 'config.json', JSON.stringify(localConfigObj));
      break;
    }
  }
};


function displayUpdate() {
  var domainRegExp = new RegExp("([a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+\\.?)");
  key1 = domainRegExp.test(MY_URL.replace("hiker://empty#", "")) === true ? RegExp.$1 : "";
  key1 = key1.replace(/^www./, "").replace(/(.com|.cn|.cc|.net|.tv|.org|.xyz|.top)$/, "").replace(/\.|-|_/, "");
  clearVar(key1 + ".url");
  clearVar(key1 + ".fl");
  clearVar(key1 + ".classify");
  clearVar(key1 + ".fold");
  clearVar(key1 + ".sel");
  let items = [];
  let remoteJson = JSON.parse(fetch(_config.remote_update, {}));
  let remoteUpdateList = remoteJson.update_list;
  for (let updateItem of remoteUpdateList) {
    let updateItemType = updateItem.type;
    let updateItemName = updateItem.name;
    let updateItemRemote = updateItem.remote;
    let updateItemVersion = updateItem.version;
    let updateItemId = updateItem.id;
    let updateItemUrl = "";

    if (updateItemType == 1) {
      updateItemUrl = $("hiker://empty").lazyRule((obj) => {
        var _config = obj.config;
        eval(obj.setLocalItemVersionById);
        eval(obj.getLocalConfig);
        setLocalItemVersionById(obj.id, obj.version);
        return obj.remote;
      }, {
          id: updateItemId,
          config: _config,
          version: updateItemVersion,
          remote: updateItemRemote,
          setLocalItemVersionById: setLocalItemVersionById + '',
          getLocalConfig: getLocalConfig + ''
        });
    }
    items.push({
      title: updateItemName + '版本: ' + getLocalItemVersionById(updateItemId, updateItemName) + '    最新: ' + updateItemVersion,
      desc: '点击更新，若无效请联系作者修复',
      url: updateItemUrl,
      col_type: 'text_1'
    });
    items.push({
      col_type: 'line_blank'
    })
  }
  let localConfig = getLocalConfig();
  localConfig.last_check_update_time = new Date().getTime();
  writeFile(_config.work_path + 'config.json', JSON.stringify(localConfig));

  items.push({
    title: '<p style="text-align: center;"><strong><font color="red">·更新日志·</font></strong><ul><li>' + remoteJson.note.join('</li><li>') + '</li></ul></p>',
    col_type: 'rich_text'
  });
  res.data = items;
  setResult(res);
}
function displaySetting() {
  function findOptTitle(opts, value) {
    let title = '';
    opts.some((item) => {
      if (item.value == value) {
        title = item.title;
        return true;
      }
      else {
        return false;
      }
    });
    return title;
  }
  let res = {};
  let items = [];
  let setting = getLocalSetting();
  for (let i = 0; i < setting.length; i++) {
    items.push({
      title: setting[i].title + ': ‘‘' + findOptTitle(setting[i].opts, setting[i].value) + '’’',
      col_type: 'text_1'
    });
    for (let j = 0; j < setting[i].opts.length; j++) {
      items.push({
        title: setting[i].opts[j].title,
        col_type: 'text_3',
        url: `hiker://empty@lazyRule=.js:` +
          `let localConfig = JSON.parse(fetch('` + _config.local_config_path + `',{}));` +
          `localConfig.setting[` + i + `].value=` + setting[i].opts[j].value + `;` +
          `writeFile('` + _config.local_config_path + `',JSON.stringify(localConfig));` +
          `refreshPage();'toast://修改成功！'`
      });
    }
  }
  res.data = items;
  setResult(res);
}
function getTureurl(true_url) {
  if (typeof RULE != "undefined") {
    url = RULE.url;
    page = pageNum;
    fypage = RULE.url;
    fypage = fypage.replace("hiker://empty#", "");
    fyclass = fypage.search("fyclass") > -1 ? tabHeader.getClass("fyclass").url : "";
    fyarea = fypage.search("fyarea") > -1 ? tabHeader.getClass("fyarea").url : "";
    fyyear = fypage.search("fyyear") > -1 ? tabHeader.getClass("fyyear").url : "";
    fysort = fypage.search("fysort") > -1 ? tabHeader.getClass("fysort").url : "";
    fyall = fyclass != "" ? fyclass : fyarea != "" ? fyarea : fyyear != "" ? fyyear : fysort;
  } else {
    fypage = MY_RULE.url.match(/(.*?)(?:\[firstPage|;)/);
    fypage = fypage != null ? fypage[1] : MY_RULE.url;
    fypage = fypage.replace("hiker://empty#", "");
    fyclass = MY_RULE.class_url;
    fyarea = MY_RULE.area_url;
    fyyear = MY_RULE.year_url;
    fysort = MY_RULE.sort_url;
    fyall = fyclass != "" ? fyclass : fyarea != "" ? fyarea : fyyear != "" ? fyyear : fysort;
    var pageRegExp = new RegExp(fypage.replace("?", "\\?").replace(/fyclass/g, fyclass).replace(/fyarea/g, fyarea).replace(/fyyear/g, fyyear).replace(/fysort/g, fysort).replace(/fyAll/g, fyall).replace(/fypage/g, "(\\d+)"));
    page = pageRegExp.test(MY_URL) === true ? RegExp.$1 : 1;
  }
  var domainRegExp = new RegExp("(https?://[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+\\.?)");
  domain = domainRegExp.test(true_url) === true ? RegExp.$1 : "";
  var f_page = "";
  var r_page = "";
  if (MY_URL.match(/\d+---(.html|\/)$/) && true_url.match(/(?:\d+)?---(\/|(\w+)?.html|(\w+)\/)$/)) {
    log(1)
    f_page = /(?:\d+)?---(\/|(\w+)?.html|(\w+)\/)$/;
    r_page = page + "---$1"
  } else if (/(\w+)\/([a-zA-Z0-9]+)_([a-zA-Z0-9]*)(.*)?_(\d+)?(.html|\/)$/.test(true_url)) {
    log(10);
    log(true_url)
    re = new RegExp(domain + "(?::\\d+)?/([a-zA-Z0-9]+)(_|/)?([a-zA-Z0-9]+)_([a-zA-Z0-9]*)(.*)?_(\\d+)?(.html|/)$");
    re3 = new RegExp(domain + "(?::\\d+)?/([a-zA-Z0-9/_]+)(\\d+_\\d+)(.html|/)$");
    if (/p_\d+/.test(MY_URL) && !/p_\d+/.test(true_url)) {
      log(11)
      f_page = /(.*).html/
      r_page = "$1_p_" + page + ".html"
    } else if (/1_1(.html|\/)$/.test(true_url)) {
      log(14)
      f_page = /1_1(.html|\/)$/;
      r_page = page + "_" + page + "$1";
    } else if (re3.test(true_url)) {
      log(12)
      f_page = /(.*)/
      r_page = domain + "/" + RegExp.$1 + page + "_" + page + RegExp.$3;
    } else if (re.test(true_url)) {
      log(13)
      page = /\d+_\d+(.html|\/)$/.test(MY_URL) ? page + "_" + page : page
      pg = RegExp.$4 == 1 ? page : RegExp.$4;
      pg1 = (pg == page && pg != '') ? RegExp.$6 : RegExp.$6 == 1 ? page : RegExp.$6 == '' ? page : RegExp.$6;
      f_page = /.*/;
      r_page = domain + "/" + RegExp.$1 + RegExp.$2 + RegExp.$3 + "_" + pg + RegExp.$5 + "_" + pg1 + RegExp.$7;
    }
  } else if (MY_URL.match(/page\/\d+(.html|\/)/)) {
    log(30)
    log(true_url)
    re = new RegExp(domain + "(?::\\d+)?/\\w+(/\\w+)?(.html|/)$");
    re1 = new RegExp(domain + "(?::\\d+)?/(.*)(.html|/)$");
    if (re1.test(true_url) && true_url.match(/page\/\d+(.html|\/)/) == null && !re.test(true_url)) {
      log(32)
      f_page = /.*/;
      r_page = domain + "/" + RegExp.$1 + "/page/" + page + RegExp.$2;
    } else if (true_url.match(/page\/\d+(.html|\/)/)) {
      log(33)
      f_page = /page\/\d+(.html|\/)/;
      r_page = 'page/' + page + '$1';
    }
  } else if (/([a-zA-Z0-9]+)(-|\/)([a-zA-Z0-9]*)(.*)?-(\d+)?(.html|\/)$/.test(true_url) && !/\d+---(.html|\/)$/.test(MY_URL)) {
    log(40)
    re = new RegExp(domain + "(?::\\d+)?/([a-zA-Z0-9]+)(-|/)?([a-zA-Z0-9]+)(.*)?-([a-zA-Z0-9]*)-(\\d+)?(.html|/)$");
    if (re.test(true_url)) {
      log(41)
      page = /\d+_\d+(.html|\/)$/.test(MY_URL) ? page + "_" + page : page
      pg = (RegExp.$5 == 1 || RegExp.$5 == '') ? page : RegExp.$5;
      pg1 = (pg == page && pg != '') ? RegExp.$6 : RegExp.$6 == 1 ? page : RegExp.$6 == '' ? page : RegExp.$6;
      f_page = /.*/;
      r_page = domain + "/" + RegExp.$1 + RegExp.$2 + RegExp.$3 + RegExp.$4 + "-" + pg + "-" + pg1 + RegExp.$7;
    }
  }

  re = new RegExp(domain + "(?::\\d+)?/([a-zA-Z0-9-]+)(?:/|_|-)(?:index)?(?:\\?)?([a-zA-Z0-9]+)(-\\d+|/\\d+|_)?(.html|/)(#t)?$")
  re1 = new RegExp(domain + "(?::\\d+)?/(?:frim|vodtype)?(?:/index|-)?([a-zA-Z0-9]+)(-\\d+)?(/index\\d*|/p\\d*)?(.html|/)?(#t)?$")
  re2 = new RegExp(domain + "(?::\\d+)?/(\\w+)/(\\w+)/(?:index\\d*|p\\d+)(.html|/)?$")
  pg = page;
  if ((re.test(MY_URL) || re1.test(MY_URL)) && page == 1 && MY_URL.match(/p\d+/) == null && true_url.match(/vod-?type-[a-zA-Z0-9-]+.html$/) == null && true_url.match(/frim\/index\d+(.html|\/)/) == null && !/-\d+(.html|\/)/.test(MY_URL)) {
    log(1000);
    pg = "";
  }
  if (/(pg|page|p)(-|_)\d+/.test(MY_URL) && !/(pg|page|p)(-|_)\d+/.test(true_url) && !/\w+\/\d+(.html|\/)$/.test(true_url)) {
    log(180)
    log(true_url)
    log(MY_URL)
    re = new RegExp("(?::\\d+)?/(.*)(-|_|/)(pg|page|p)(-|_)\\d+[a-zA-Z0-9-_]*(.html|/)?");
    pg = re.test(MY_URL) === true ? RegExp.$2 + RegExp.$3 + RegExp.$4 + page + RegExp.$5 : "";
    log(pg)
    true_url = /(.html|\/)$/.test(true_url) ? true_url.replace(/(.*)(.html|\/)$/, "$1" + pg) : true_url + pg;
  } else if (/(pg|page|p)(-|_)\d+/.test(true_url)) {
    log(190)
    true_url = true_url.replace(/(pg|page|p)(-|_)\d+/, "$1$2" + page)
  } else if (re1.test(true_url) && r_page == "" && f_page == "") {
    log(200)
    pm = RegExp.$1;
    pm = /movie\d+(.html|\/)$/.test(true_url) ? pm.replace("movie", "") : pm;
    true_url = fypage.replace(/fyclass/g, pm).replace(/fyarea/g, fyarea).replace(/fyyear/g, fyyear).replace(/fysort/g, fysort).replace(/fyAll/g, pm).replace(/fypage/g, pg);
    true_url = true_url.replace(/movie\d+(.html|\/)$/, "$1");
  } else if (re.test(true_url) && r_page == "" && f_page == "") {
    log(210)
    true_url = fypage.replace(/fyclass/g, RegExp.$2).replace(/fyarea/g, fyarea).replace(/fyyear/g, fyyear).replace(/fysort/g, fysort).replace(/fyAll/g, RegExp.$2).replace(/fypage/g, pg);
  } else if (true_url.search("search") > -1 || true_url.search("ListInfo.php") > -1) {
    log(220)
    true_url = true_url + "&page=" + page;
  } else if (true_url.search("1--time") > -1 && r_page == "" && f_page == "") {
    log(230)
    true_url = true_url.replace("1--time", page + "--time");
  } else if (true_url.search("ianfen") > -1) {
    log(240)
    true_url = true_url.replace("ianfen", "ianf" + page + "en");
  } else if (re2.test(true_url)) {
    log(260)
    true_url = true_url.replace(/index\d*(.html|\/)$/, "index" + pg + "$1").replace(/p\d+(.html|\/)$/, "p" + pg + "$1");
  } else {
    log(270)
    log(r_page)
    true_url = true_url.replace(f_page, r_page)
  }
  if (page == 1) {
    true_url = true_url.replace(/([a-zA-Z0-9]+)_.html$/, "$1.html").replace(/\/(\d+)-(.html|\/)$/, "/$1.html")
  }
  true_url = MY_URL.search("/show/") > 0 ? true_url.replace("/type/", "/show/") : true_url.replace("/show/", "/type/");
  true_url = MY_URL.search("-list-") > 0 ? true_url.replace("-type-", "-list-") : true_url.replace("-list-", "-type-");
  true_url = MY_URL.search("-select-") > 0 ? true_url.replace("-read-", "-select-") : true_url;
  true_url = MY_URL.search("-show-") > 0 ? true_url.replace("-type-", "-show-") : true_url;
  return true_url;
}

function unique(arr) {
  return arr.filter(function (item, index, arr) {
    //当前元素，在原始数组中的第一个索引==当前索引值，否则返回当前元素
    return arr.indexOf(item, 0) === index;
  });
}

if (!queryUpdate()) {
  showLoading('加载中')
  try {
    fl_selectors = [".header-menu", ".myui-header__menu", ".stui-header__menu", ".mo-navs-left", ".fed-pops-list", ".details-nav-ul", ".top-nav", ".nav-list", ".nav-down-2", ".nav-down-pc", ".pcmenu", ".top_nav", ".nav_list", "#nav_menu", ".headerChannelList", ".menulist", ".topLabel", ".type-slide", ".con", ".nav-menu-items", ".nav_left", ".navbar-nav", "#navbar-feifeicms", ".ff-gallery", "#header", ".nav", "ul.cf", "#menuBar", "#sddm", "#nav", ".ff-nav", ".menu", ".swiper-wrapper", ".fed-nav-left:eq(1)"];
    classify_selectors = ["body&&.myui-screen__list", "body&&.stui-screen__list", "body&&.macplus-screen__list", "body&&.screen__list", "body&&.afc1", "body&&.breadcrumb", ".selectList&&li", "#screenbox&&ul", "#classCon&&ul", "#collapse&&ul",".content-meun&&ul", ".scon&&dl", ".typelist&&dl", "body&&#sj-gjsy dl", ".sy-nav-down&&dl", "body&&.screen_list", "body&&.filter_line", "body&&.stui-screen__min", ".selectList&&li", ".hy-min-screen&&dl", ".stui-pannel-box&&dl", ".channel-list&&ul", ".slideDown-box&&ul", ".list_type&&ul", "body&&.nav-tabs", "body&&.nowrap-box", "body&&.nav-list", "body&&.block-box-items", "body&&.scroll-content", ".category&&dd", ".dl-horizontal&&dd", "body&&.hl-filter-list", ".mo-main-info&&dl", ".lists-content&&dl", ".fed-casc-list&&dl", ".fed-scre-list&&dl"];
    fl_sub_selector = 'body&&a:not(:contains(下载)):not(:contains(app)):not(:contains(导航)):not(:contains(求片)):not(:contains(留言)):not(:contains(网)):not(:contains(更新)):not(:contains(资讯)):not(:contains(中心)):not(:contains(听)):not(:contains(签到)):not(:contains(排行)):not(:contains(更多)):not(:contains(观看)):not(:contains(全部)):not(:contains(明星)):not(:contains(专题)):not(:contains(直播)):not(:contains(演员)):not(:contains(角色))';
    classify_sub_selector = 'body&&a';
    let d = [];
    var domainRegExp = new RegExp("([a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+\\.?)");
    key1 = domainRegExp.test(MY_URL) === true ? RegExp.$1 : "";
    key1 = key1.replace(/^www./, "").replace(/(.com|.cn|.cc|.net|.tv|.org|.xyz|.top)$/, "").replace(/\.|-|_/, "");
    filter_arr = ["首页", "频道", "推荐", "韩漫", "搜索", "影评", "公告", "头条", "合集", "最新", "APP", "榜单", "节目", "角色", "图库", "剧情", "新闻", "历史", "导航", "分类", "历史记录", "会员"]
    /*变量 最好更改
    ****baoqingwl.url
    ****baoqingwl.fl
    ****baoqingwl.classify
    *
    *需修改
    ****翻页  true_url
    ****列表 fl classify
    ****分类  sub_classify
    */
    //自定义颜色
    const Color = "#FA7298";

    const a = MY_URL.replace(/%%/g, "");
    let true_url = getVar(key1 + ".url", a)
    true_url = getTureurl(true_url);
    fl_cateManual = {};

    log(true_url);
    log(MY_URL);
    log(key1);
    //setError(true_url);
    headers = {};
    if (MY_RULE.url.search("gbk") > 0) {
      headers = { 'content-type': 'charset=GBK' }
    }
    if (MY_RULE.ua === "pc") {
      html1 = fetch(true_url, { headers: headers });
    } else {
      html1 = request(true_url, { headers: headers });
    }
    if (html1.search("检测中") > -1) {
      code = html1.match(/btwaf=(\d+)/)[1];
      log(code)
      true_url = true_url.indexOf("?") > -1 ? true_url + "&btwaf=" + code : true_url + "?btwaf=" + code;
      if (MY_RULE.ua === "pc") {
        html1 = fetch(true_url, { headers: headers });
      } else {
        html1 = request(true_url, { headers: headers });
      }
    }
    log(html1)
    if (html1.search("筛选页功能关闭中") > -1 || html1.search("页面不存在") > -1 || html1.search("搜索系统关闭") > -1 || html1.search("安全验证") > -1) {
      confirm({ title: "筛选页", content: "筛选页功能关闭中", confirm: "refreshPage()" });
      fold = '0';
    }
    const html = html1;
    const empty = "hiker://empty"
    //获取列表 
    let fl = [];
    for (i = 0; i < fl_selectors.length; i++) {
      fl = parseDomForArray(html, fl_selectors[i]);
      if (fl.length > 0) {
        log(fl_selectors[i]);
        break;
      }
    }

    if (fl.length > 0) {
      let classify = [];//其他分类列表
      for (i = 0; i < classify_selectors.length; i++) {
        classify = parseDomForArray(html, classify_selectors[i]);
        if (classify.length > 0) {
          log(classify_selectors[i]);
          break;
        }
      }


      let init_cate = [];
      for (let i = 0; i < 20; i++) {
        init_cate.push("0")
      }
      const fold = getVar(key1 + ".fold", "0")
      // 取四金刚缓存
      init_cate[0] = "-1";
      const cate_temp_json = getVar(key1 + ".fl", JSON.stringify(init_cate))
      const cate_temp = JSON.parse(cate_temp_json)

      // 取缓存
      init_cate[0] = "0";
      const classify_json = getVar(key1 + ".classify", JSON.stringify(init_cate))
      const classify_temp = JSON.parse(classify_json)
      sel_json = getVar(key1 + ".sel", JSON.stringify([0]));
      sel_arr = JSON.parse(sel_json);
      if (parseInt(page) === 1) {
        items.push({
          title: fold === '1' ? '““””<b><span style="color: #FF0000">∨</span></b>' : '““””<b><span style="color: #1aad19">∧</span></b>',
          url: $(empty).lazyRule((params) => {
            putVar(params.key1 + ".fold", params.fold === '1' ? '0' : '1');
            refreshPage(false);
            return "hiker://empty"
          }, {
              key1: key1,
              fold: fold
            }),
          col_type: 'scroll_button',
        })
        fl.forEach((category, index) => {
          //四大金刚的分类	
          category = category.replace(/(class=".*?"|class='.*?')/g, "");
          let sub_classify = parseDomForArray(category, fl_sub_selector);////需修改
          sub_classify = unique(sub_classify);
          sub_classify.forEach((item, key) => {
            let title = parseDomForHtml(item, 'a&&Text')
            title = title.replace(/共(\d+)条/, "").trim();
            url = parseDom(item, 'a&&href');
            if (!filter_arr.includes(title)) {
              filter_arr.push(title);
              if (getTureurl(url) === true_url || cate_temp[index] === key.toString()) {
                cate_temp[index] = key.toString();
                putVar(key1 + ".fl", JSON.stringify(cate_temp));
                sel_arr[index] = title;
                putVar(key1 + ".sel", JSON.stringify(sel_arr));
              }
              if (title != "") {
                items.push({
                  title: key.toString() === cate_temp[index] ? '““””<b><font color=' + Color + '>' + title + ' </font></b>' : title,
                  url: $(parseDom(item, 'a&&href')).lazyRule((params) => {
                    if (params.title.match(/^(?:全部|已选|类型|剧情|地区|年份|年代|剧情|分类|语言|字母|排序)/) == null) {
                      params.sel_arr = [params.title];
                    }
                    putVar(params.key1 + ".sel", params.sel_arr);
                    params.cate_temp[params.index] = params.key.toString()
                    putVar(params.key1 + ".fl", JSON.stringify(params.cate_temp))
                    putVar(params.key1 + ".classify", JSON.stringify(params.init_cate))
                    putVar(params.key1 + ".url", input)
                    refreshPage(true)
                    return "hiker://empty"
                  }, {
                      cate_temp: cate_temp,
                      index: index,
                      key: key,
                      page: page,
                      key1: key1,
                      sel_arr: sel_arr,
                      title: title,
                      init_cate: init_cate
                    }),
                  col_type: 'scroll_button',
                })
              }
            }


          })
          items.push({
            col_type: "blank_block"
          });
        })

        //if (fold === '1') {
        //其他分类
        if (classify.join("").replace(/<\/?.+?\/?>/g, "").match(/(?:已选)/) == null) {
          items.push({
            title: "已选",
            url: $().lazyRule(() => {
              refreshPage(true)
              return "hiker://empty"
            }),
            col_type: 'scroll_button'
          });
          sel_arr = JSON.parse(getVar(key1 + ".sel", JSON.stringify([])));
          sel_arr.forEach((sel) => {
            items.push({
              title: sel,
              url: $().lazyRule(() => {
                refreshPage(true)
                return "hiker://empty"
              }),
              col_type: 'scroll_button'
            });
          });
          items.push({
            col_type: "blank_block"
          });
        }
        classify.forEach((category, index) => {
          if (parseDomForHtml(category, "body&&Text").match(/(?:下一页|动漫)/) == null) {
            let sub_classify = parseDomForArray(category, classify_sub_selector);////需修改
            if (sub_classify.length > 0 && sub_classify.join("").replace(/<\/?.+?\/?>/g, "").match(/^(?:全部|已选|类型|剧情|地区|年份|年代|剧情|分类|语言|字母|排序)/) == null) {
              sub_classify.unshift("<a href=" + MY_URL + ">全部影片</a>");
            }
            sub_classify.forEach((item, key) => {
              let title = parseDomForHtml(item, 'a&&Text')
              if (title !== '') {

                items.push({
                  title: key.toString() === classify_temp[index] ? '““””<b><font color=' + Color + '>' + title + ' </font></b>' : title,
                  url: $(parseDom(item, 'a&&href')).lazyRule((params) => {
                    if (params.title.match(/^(?:全部|已选|类型|剧情|地区|年份|年代|剧情|分类|语言|字母|排序)/) == null) {
                      params.sel_arr[params.index] = params.title;
                    }
                    putVar(params.key1 + ".sel", params.sel_arr);
                    params.classify_temp[params.index] = params.key.toString()
                    putVar(params.key1 + ".classify", JSON.stringify(params.classify_temp))
                    putVar(params.key1 + ".url", input)
                    refreshPage(true)
                    return "hiker://empty"
                  }, {
                      classify_temp: classify_temp,
                      sel_arr: sel_arr,
                      title: title,
                      index: index,
                      key: key,
                      page: page,
                      sel_arr: sel_arr,
                      key1: key1
                    }),
                  col_type: 'scroll_button',
                })
              }
            });
            items.push({
              col_type: "blank_block"
            });
          }
        });

        //}

      }
    } else {
      clearVar(key1 + ".url");
      clearVar(key1 + ".fl");
      clearVar(key1 + ".classify");
      clearVar(key1 + ".fold");
      clearVar(key1 + ".sel");
      log(html)
    }
  } catch (e) {
    displayUpdate();
    setError(e);
  }
  hideLoading()
}